/*
 * ValuedGoodsInfoListItem.java
 * business
 *
 * Created by SunDing on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.displaylistitem;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import com.yidiandao.business.R;
import com.yidiandao.business.data.bean.Goods;
import com.yidiandao.business.data.bean.ValueBean;
import com.yidiandao.business.ui.orderabout.rate.RateActivity;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;
import com.yidiandao.business.ui.widget.listview.viewholder.RateGoodsInfoHolder;
import com.yidiandao.business.utils.ImageLoader;

/** 评价的物品信息 */
public class RateGoodsInfoListItem extends DisplayListItem<RateGoodsInfoHolder, Goods> {

    public RateGoodsInfoListItem(Goods dataBean) {
        super(dataBean);
    }

    @Override
    public void onShow(final Context context, RateGoodsInfoHolder holder) {
        //商品图片
        ImageLoader.loadImage(context, holder.mIvGoodsImage, data.getGoodsThumb());
        //商名
        holder.mTvTitle.setText(data.getGoodsName());

        if (data.getSuccess() == 0) {
            holder.mTvValue.setBackgroundResource(R.drawable.sl_text_rect);
            holder.mTvValue.setText(R.string.order_valued1);
            holder.mTvValue.setOnClickListener(
                    new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            ValueBean bean = new ValueBean();
                            bean.setRec_id(data.getRecId());
                            bean.setGoods_id(data.getGoodsId());
                            bean.setGoods_thumb(data.getGoodsThumb());
                            bean.setShowRatingBar(false);
                            RateActivity.actionStart((Activity) context, bean);
                        }
                    });
        } else {
            holder.mTvValue.setText(R.string.order_value_success);
            holder.mTvValue.setBackgroundResource(R.drawable.bg_text_gray_normal);
            holder.mTvValue.setOnClickListener(null);
        }
    }

    @Override
    public String getDisplayItemTag() {
        return RateGoodsInfoListItem.class.getSimpleName();
    }

    @Override
    public Class<RateGoodsInfoHolder> getViewHolderClazz() {
        return RateGoodsInfoHolder.class;
    }
}
